package thread;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/4/27
 * Time:11:14
 * 线程优先级演示
 **/
public class ThreadDemo8 {
    public static void main(String[] args) {
        //定义方法
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                System.out.println("线程名称"+Thread.currentThread().getName());
            }
        };
        for (int i = 0; i < 10; i++) {
            Thread t1 = new Thread(runnable,"张三");
            Thread t2 = new Thread(runnable,"李四");
            Thread t3 = new Thread(runnable,"王五");
            t1.setPriority(1);//优先级最小
            //t1.setPriority(Thread.MIN_PRIORITY);//优先级最小
            t3.setPriority(Thread.MAX_PRIORITY);//优先级最大//10
            t1.start();
            t2.start();
            t3.start();
        }
    }
}
